package com.piccolo.wrapper.client.component;

import java.util.List;

import com.piccolo.wrapper.client.component.Overlay.PCameraOverlay;

/**
 * @author Maria Patrickson
 * @version 1.0
 */
public class PCamera extends PNode
{
	/**
	 * Creates a new PCamera
	 */
	public PCamera()
	{
		overlay = PCameraOverlay.create();
	}
	
	/**
	 * Creates a new PCamera using the specified JavaScript overlay object.
	 * @param overlay
	 */
	public PCamera(PCameraOverlay overlay)
	{
		this.overlay = overlay;
	}

	/**
	 * Animate the cameras view transform from its current value when the activity 
	 * starts to the new destination transform value.
	 * @param transform
	 * @param duration
	 */
	public void animateViewToTransform(PTransform transform, double duration)
	{
		((PCameraOverlay) overlay).animateViewToTransform(transform.getOverlay(), duration);
	}
   
	/**
	 * Adds the supplied yayer to this camera
	 * @param layer
	 */
    public void addLayer(PLayer layer) 
    {
    	((PCameraOverlay) overlay).addLayer(layer);
    }

    /**
     * Removes the specified layer from this camera
     * @param layer
     */
    public void removeLayer(PLayer layer) 
    {
    	((PCameraOverlay) overlay).removeLayer(layer);
    }
    
	/**
	 * @return The layers attached to this PCamera
	 */
	public List<PLayer> getLayers()
	{
		return ((PCameraOverlay) overlay).getLayers();
	}

	/**
	 * Returns the number of layers attached to this camera
	 * @return
	 */
	public int getLayerCount()
	{
		return ((PCameraOverlay) overlay).getLayerCount();
	}

	public List<PNode> getPickedNodes(double x, double y) 
    {
    	return ((PCameraOverlay) overlay).getPickedNodes(x, y);
    }

    public void setViewTransform(PTransform transform) 
    {
    	((PCameraOverlay) overlay).setViewTransform(transform);
    }
}